<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        ref="crud"
        :data="data"
        :option="option"
        :table-loading="loading"
        @on-load="listdata"
        @refresh-change="listdata"
        @search-change="searchChange"
        :page.sync="page"
      >
        <template slot="menuLeft">
          <el-button
            v-if=""
            class="filter-item"
            plain
            type="primary"
            size="small"
            icon="el-icon-download"
            @click="exportExcel"
          >导出
          </el-button>
        </template>


      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
  import {option} from "@/const/crud/houxin/channel";
  import {fetchList} from "@/api/houxin/channel";

  export default {
    data() {
      return {
        option: option,
        data: [],
        loading: true,
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 20, // 每页显示多少条
        },
      };
    },
    methods: {
      listdata() {
        this.loading = true;
        fetchList({
          pageIndex: this.page.currentPage,
          pageSize: this.page.pageSize,
        }).then((r) => {
          console.log(r.data.data.list);
          this.data = r.data.data.list;
          this.page.total = r.data.data.total;
          this.loading = false;
        });
      },
      searchChange(form, done) {
        this.query = form;
        fetchList({
          pageIndex: this.page.currentPage,
          pageSize: this.page.pageSize,
          ...form,
        }).then((r) => {
          this.data = r.data.data.list;
          this.page.total = r.data.data.total;
          this.loading = false;
        });
        done();
      },
      sizeChange(pageSize) {
        this.page.pageSize = pageSize;
      },
      rowEdit(row) {
        this.$refs["ChannelForm"].edit(row);
      },
      exportExcel() {
        this.downBlobFile("/admin/channel/exportChannelStatisticInfo", this.query, "channel.xlsx");
      }
    },
  };
</script>

<style>
</style>
